package com.yohann.eduservice.controller;


import com.yohann.commonutils.result.R;
import com.yohann.eduservice.entity.EduSubject;
import com.yohann.eduservice.entity.vo.OneSubject;
import com.yohann.eduservice.service.EduSubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author Yohann
 * @since 2020-08-07
 */
@RestController
@RequestMapping("/edu-service/subject")
public class EduSubjectController {
    @Autowired
    private EduSubjectService subjectService;

    /**
     * 添加课程分类
     * @param file
     * @return
     */
    @PostMapping("add")
    public R addSubject(MultipartFile file){
        subjectService.saveSubject(file, subjectService);
        return R.ok();
    }

    /**
     * 获取所有科目
     * @return
     */
    @GetMapping("list")
    public R getListSubject(){
        List<OneSubject> list = subjectService.getAllOneSubject();
        return R.ok().data("list",list);
    }
}

